<?php
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
require_once($_SERVER['DOCUMENT_ROOT']."/Modules/MF93FL27/modconf.mex");
MYTCONN(); 
	$SUM = 0;
	$GET = $GLOBALS['MYT']->db_array("SELECT OriNombre, ROUND(SUM(bac_Balance)) AS BnsAmount FROM `officeschema`.`bonusaccounts`
			LEFT OUTER JOIN bonuscards ON bac_Card = car_ID
			LEFT OUTER JOIN origenes ON car_Office = OriNumero
			GROUP BY car_Office");
	echo '<div class="title">Posicao de Contas de Pontos por Loja '; 
	mn_field('button','ED','pac_Print','Imprimir','','','','" onclick="printdiv(\'rsAccountPos\');');
	echo '</div>
	<div id="rsAccountPos">
	<table style="width:98%;">
	<tr style="height:20px;text-align:center"><td>Loja</td><td>Pontos em vigor</td>';		
	for($i=1;$i<=$GET[0];$i++) {
	$SUM += $GET[$i]['BnsAmount'];
	echo '<tr bgcolor="'.gridlines($i).'" style="height:20"><td>'.$GET[$i]['OriNombre'].'</td>
	<td style="text-align:right">'.number_format($GET[$i]['BnsAmount'],0).'</td></tr>';
	
	}
	echo '<tr style="height:20;">
	<td>Total</td>
	<td style="text-align:right">'.number_format($SUM,0).'</td>
	</tr></table>
	</div>';